package com.group1.realtime.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisUtil {

    private static JedisPool pool;

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(100);
        config.setMaxIdle(20);
        config.setMinIdle(2);

        config.setMaxWaitMillis(10 * 1000);
        config.setTestOnCreate(true);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);

        pool = new JedisPool(config, "hadoop102");
    }

    public static Jedis getRedisClient(){

        Jedis jedis = pool.getResource();
        jedis.select(1);
        return jedis;

    }
}
